#############################################################################################
#                                                                                           #
#                   Copyright 2010-2013 Ning, Inc.                                          #
#                   Copyright 2014 Groupon, Inc.                                            #
#                   Copyright 2014 The Billing Project, LLC                                 #
#                                                                                           #
#      The Billing Project licenses this file to you under the Apache License, version 2.0  #
#      (the "License"); you may not use this file except in compliance with the             #
#      License.  You may obtain a copy of the License at:                                   #
#                                                                                           #
#          http://www.apache.org/licenses/LICENSE-2.0                                       #
#                                                                                           #
#      Unless required by applicable law or agreed to in writing, software                  #
#      distributed under the License is distributed on an "AS IS" BASIS, WITHOUT            #
#      WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the            #
#      License for the specific language governing permissions and limitations              #
#      under the License.                                                                   #
#                                                                                           #
#############################################################################################


#
#                       DO NOT EDIT!!!
#    File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
#


module Killbill
  module Plugin
    module Api

      java_package 'org.killbill.billing.payment.api'
      class PaymentApi

        include org.killbill.billing.payment.api.PaymentApi

        def initialize(real_java_api)
          @real_java_api = real_java_api
        end


        java_signature 'Java::org.killbill.billing.payment.api.Payment createAuthorization(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_authorization(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentMethodId [type = java.util.UUID]
          paymentMethodId = java.util.UUID.fromString(paymentMethodId.to_s) unless paymentMethodId.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentExternalKey [type = java.lang.String]
          paymentExternalKey = paymentExternalKey.to_s unless paymentExternalKey.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_authorization(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createAuthorizationWithPaymentControl(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.payment.api.PaymentOptions, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_authorization_with_payment_control(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, paymentOptions, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentMethodId [type = java.util.UUID]
          paymentMethodId = java.util.UUID.fromString(paymentMethodId.to_s) unless paymentMethodId.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentExternalKey [type = java.lang.String]
          paymentExternalKey = paymentExternalKey.to_s unless paymentExternalKey.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for paymentOptions [type = org.killbill.billing.payment.api.PaymentOptions]
          paymentOptions = paymentOptions.to_java unless paymentOptions.nil?

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_authorization_with_payment_control(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, paymentOptions, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createCapture(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_capture(account, paymentId, amount, currency, paymentTransactionExternalKey, properties, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_capture(account, paymentId, amount, currency, paymentTransactionExternalKey, properties, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createCaptureWithPaymentControl(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.payment.api.PaymentOptions, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_capture_with_payment_control(account, paymentId, amount, currency, paymentTransactionExternalKey, properties, paymentOptions, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for paymentOptions [type = org.killbill.billing.payment.api.PaymentOptions]
          paymentOptions = paymentOptions.to_java unless paymentOptions.nil?

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_capture_with_payment_control(account, paymentId, amount, currency, paymentTransactionExternalKey, properties, paymentOptions, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createPurchase(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_purchase(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentMethodId [type = java.util.UUID]
          paymentMethodId = java.util.UUID.fromString(paymentMethodId.to_s) unless paymentMethodId.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentExternalKey [type = java.lang.String]
          paymentExternalKey = paymentExternalKey.to_s unless paymentExternalKey.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_purchase(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createPurchaseWithPaymentControl(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.payment.api.PaymentOptions, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_purchase_with_payment_control(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, paymentOptions, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentMethodId [type = java.util.UUID]
          paymentMethodId = java.util.UUID.fromString(paymentMethodId.to_s) unless paymentMethodId.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentExternalKey [type = java.lang.String]
          paymentExternalKey = paymentExternalKey.to_s unless paymentExternalKey.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for paymentOptions [type = org.killbill.billing.payment.api.PaymentOptions]
          paymentOptions = paymentOptions.to_java unless paymentOptions.nil?

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_purchase_with_payment_control(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, paymentOptions, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createVoid(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_void(account, paymentId, paymentTransactionExternalKey, properties, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_void(account, paymentId, paymentTransactionExternalKey, properties, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createVoidWithPaymentControl(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.payment.api.PaymentOptions, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_void_with_payment_control(account, paymentId, paymentTransactionExternalKey, properties, paymentOptions, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for paymentOptions [type = org.killbill.billing.payment.api.PaymentOptions]
          paymentOptions = paymentOptions.to_java unless paymentOptions.nil?

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_void_with_payment_control(account, paymentId, paymentTransactionExternalKey, properties, paymentOptions, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createRefund(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_refund(account, paymentId, amount, currency, paymentTransactionExternalKey, properties, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_refund(account, paymentId, amount, currency, paymentTransactionExternalKey, properties, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createRefundWithPaymentControl(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.payment.api.PaymentOptions, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_refund_with_payment_control(account, paymentId, amount, currency, paymentTransactionExternalKey, properties, paymentOptions, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for paymentOptions [type = org.killbill.billing.payment.api.PaymentOptions]
          paymentOptions = paymentOptions.to_java unless paymentOptions.nil?

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_refund_with_payment_control(account, paymentId, amount, currency, paymentTransactionExternalKey, properties, paymentOptions, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createCredit(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_credit(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentMethodId [type = java.util.UUID]
          paymentMethodId = java.util.UUID.fromString(paymentMethodId.to_s) unless paymentMethodId.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentExternalKey [type = java.lang.String]
          paymentExternalKey = paymentExternalKey.to_s unless paymentExternalKey.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_credit(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createCreditWithPaymentControl(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.payment.api.PaymentOptions, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_credit_with_payment_control(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, paymentOptions, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentMethodId [type = java.util.UUID]
          paymentMethodId = java.util.UUID.fromString(paymentMethodId.to_s) unless paymentMethodId.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentExternalKey [type = java.lang.String]
          paymentExternalKey = paymentExternalKey.to_s unless paymentExternalKey.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for paymentOptions [type = org.killbill.billing.payment.api.PaymentOptions]
          paymentOptions = paymentOptions.to_java unless paymentOptions.nil?

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_credit_with_payment_control(account, paymentMethodId, paymentId, amount, currency, paymentExternalKey, paymentTransactionExternalKey, properties, paymentOptions, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createChargeback(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_chargeback(account, paymentId, amount, currency, paymentTransactionExternalKey, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_chargeback(account, paymentId, amount, currency, paymentTransactionExternalKey, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment createChargebackWithPaymentControl(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.math.BigDecimal, Java::org.killbill.billing.catalog.api.Currency, Java::java.lang.String, Java::org.killbill.billing.payment.api.PaymentOptions, Java::org.killbill.billing.util.callcontext.CallContext)'
        def create_chargeback_with_payment_control(account, paymentId, amount, currency, paymentTransactionExternalKey, paymentOptions, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for amount [type = java.math.BigDecimal]
          if amount.nil?
            amount = java.math.BigDecimal::ZERO
          else
            amount = java.math.BigDecimal.new(amount.to_s)
          end

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          currency = Java::org.killbill.billing.catalog.api.Currency.value_of( currency.to_s ) unless currency.nil?

          # conversion for paymentTransactionExternalKey [type = java.lang.String]
          paymentTransactionExternalKey = paymentTransactionExternalKey.to_s unless paymentTransactionExternalKey.nil?

          # conversion for paymentOptions [type = org.killbill.billing.payment.api.PaymentOptions]
          paymentOptions = paymentOptions.to_java unless paymentOptions.nil?

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.create_chargeback_with_payment_control(account, paymentId, amount, currency, paymentTransactionExternalKey, paymentOptions, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment notifyPendingTransactionOfStateChanged(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::boolean, Java::org.killbill.billing.util.callcontext.CallContext)'
        def notify_pending_transaction_of_state_changed(account, paymentTransactionId, isSuccess, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentTransactionId [type = java.util.UUID]
          paymentTransactionId = java.util.UUID.fromString(paymentTransactionId.to_s) unless paymentTransactionId.nil?

          # conversion for isSuccess [type = boolean]
          isSuccess = isSuccess.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(isSuccess)

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.notify_pending_transaction_of_state_changed(account, paymentTransactionId, isSuccess, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment notifyPendingTransactionOfStateChangedWithPaymentControl(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::boolean, Java::org.killbill.billing.payment.api.PaymentOptions, Java::org.killbill.billing.util.callcontext.CallContext)'
        def notify_pending_transaction_of_state_changed_with_payment_control(account, paymentTransactionId, isSuccess, paymentOptions, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentTransactionId [type = java.util.UUID]
          paymentTransactionId = java.util.UUID.fromString(paymentTransactionId.to_s) unless paymentTransactionId.nil?

          # conversion for isSuccess [type = boolean]
          isSuccess = isSuccess.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(isSuccess)

          # conversion for paymentOptions [type = org.killbill.billing.payment.api.PaymentOptions]
          paymentOptions = paymentOptions.to_java unless paymentOptions.nil?

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.notify_pending_transaction_of_state_changed_with_payment_control(account, paymentTransactionId, isSuccess, paymentOptions, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::java.util.List getAccountPayments(Java::java.util.UUID, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.TenantContext)'
        def get_account_payments(accountId, withPluginInfo, properties, context)

          # conversion for accountId [type = java.util.UUID]
          accountId = java.util.UUID.fromString(accountId.to_s) unless accountId.nil?

          # conversion for withPluginInfo [type = boolean]
          withPluginInfo = withPluginInfo.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(withPluginInfo)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.get_account_payments(accountId, withPluginInfo, properties, context)
            # conversion for res [type = java.util.List]
            tmp = []
            (res || []).each do |m|
              # conversion for m [type = org.killbill.billing.payment.api.Payment]
              m = Killbill::Plugin::Model::Payment.new.to_ruby(m) unless m.nil?
              tmp << m
            end
            res = tmp
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment getPayment(Java::java.util.UUID, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.TenantContext)'
        def get_payment(paymentId, withPluginInfo, properties, context)

          # conversion for paymentId [type = java.util.UUID]
          paymentId = java.util.UUID.fromString(paymentId.to_s) unless paymentId.nil?

          # conversion for withPluginInfo [type = boolean]
          withPluginInfo = withPluginInfo.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(withPluginInfo)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.get_payment(paymentId, withPluginInfo, properties, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.Payment getPaymentByExternalKey(Java::java.lang.String, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.TenantContext)'
        def get_payment_by_external_key(paymentExternalKey, withPluginInfo, properties, context)

          # conversion for paymentExternalKey [type = java.lang.String]
          paymentExternalKey = paymentExternalKey.to_s unless paymentExternalKey.nil?

          # conversion for withPluginInfo [type = boolean]
          withPluginInfo = withPluginInfo.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(withPluginInfo)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.get_payment_by_external_key(paymentExternalKey, withPluginInfo, properties, context)
            # conversion for res [type = org.killbill.billing.payment.api.Payment]
            res = Killbill::Plugin::Model::Payment.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.util.entity.Pagination getPayments(Java::java.lang.Long, Java::java.lang.Long, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.TenantContext)'
        def get_payments(offset, limit, withPluginInfo, properties, context)

          # conversion for offset [type = java.lang.Long]
          offset = offset

          # conversion for limit [type = java.lang.Long]
          limit = limit

          # conversion for withPluginInfo [type = boolean]
          withPluginInfo = withPluginInfo.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(withPluginInfo)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
          context = context.to_java unless context.nil?
          res = @real_java_api.get_payments(offset, limit, withPluginInfo, properties, context)
          # conversion for res [type = org.killbill.billing.util.entity.Pagination]
          res = Killbill::Plugin::Model::Pagination.new.to_ruby(res) unless res.nil?
          return res
        end

        java_signature 'Java::org.killbill.billing.util.entity.Pagination searchPayments(Java::java.lang.String, Java::java.lang.Long, Java::java.lang.Long, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.TenantContext)'
        def search_payments(searchKey, offset, limit, withPluginInfo, properties, context)

          # conversion for searchKey [type = java.lang.String]
          searchKey = searchKey.to_s unless searchKey.nil?

          # conversion for offset [type = java.lang.Long]
          offset = offset

          # conversion for limit [type = java.lang.Long]
          limit = limit

          # conversion for withPluginInfo [type = boolean]
          withPluginInfo = withPluginInfo.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(withPluginInfo)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
          context = context.to_java unless context.nil?
          res = @real_java_api.search_payments(searchKey, offset, limit, withPluginInfo, properties, context)
          # conversion for res [type = org.killbill.billing.util.entity.Pagination]
          res = Killbill::Plugin::Model::Pagination.new.to_ruby(res) unless res.nil?
          return res
        end

        java_signature 'Java::java.util.UUID addPaymentMethod(Java::org.killbill.billing.account.api.Account, Java::java.lang.String, Java::java.lang.String, Java::boolean, Java::org.killbill.billing.payment.api.PaymentMethodPlugin, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
        def add_payment_method(account, paymentMethodExternalKey, pluginName, setDefault, paymentMethodInfo, properties, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentMethodExternalKey [type = java.lang.String]
          paymentMethodExternalKey = paymentMethodExternalKey.to_s unless paymentMethodExternalKey.nil?

          # conversion for pluginName [type = java.lang.String]
          pluginName = pluginName.to_s unless pluginName.nil?

          # conversion for setDefault [type = boolean]
          setDefault = setDefault.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(setDefault)

          # conversion for paymentMethodInfo [type = org.killbill.billing.payment.api.PaymentMethodPlugin]
          paymentMethodInfo = paymentMethodInfo.to_java unless paymentMethodInfo.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.add_payment_method(account, paymentMethodExternalKey, pluginName, setDefault, paymentMethodInfo, properties, context)
            # conversion for res [type = java.util.UUID]
            res = res.nil? ? nil : res.to_s
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::java.util.List getAccountPaymentMethods(Java::java.util.UUID, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.TenantContext)'
        def get_account_payment_methods(accountId, withPluginInfo, properties, context)

          # conversion for accountId [type = java.util.UUID]
          accountId = java.util.UUID.fromString(accountId.to_s) unless accountId.nil?

          # conversion for withPluginInfo [type = boolean]
          withPluginInfo = withPluginInfo.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(withPluginInfo)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.get_account_payment_methods(accountId, withPluginInfo, properties, context)
            # conversion for res [type = java.util.List]
            tmp = []
            (res || []).each do |m|
              # conversion for m [type = org.killbill.billing.payment.api.PaymentMethod]
              m = Killbill::Plugin::Model::PaymentMethod.new.to_ruby(m) unless m.nil?
              tmp << m
            end
            res = tmp
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.PaymentMethod getPaymentMethodById(Java::java.util.UUID, Java::boolean, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.TenantContext)'
        def get_payment_method_by_id(paymentMethodId, includedInactive, withPluginInfo, properties, context)

          # conversion for paymentMethodId [type = java.util.UUID]
          paymentMethodId = java.util.UUID.fromString(paymentMethodId.to_s) unless paymentMethodId.nil?

          # conversion for includedInactive [type = boolean]
          includedInactive = includedInactive.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(includedInactive)

          # conversion for withPluginInfo [type = boolean]
          withPluginInfo = withPluginInfo.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(withPluginInfo)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.get_payment_method_by_id(paymentMethodId, includedInactive, withPluginInfo, properties, context)
            # conversion for res [type = org.killbill.billing.payment.api.PaymentMethod]
            res = Killbill::Plugin::Model::PaymentMethod.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.payment.api.PaymentMethod getPaymentMethodByExternalKey(Java::java.lang.String, Java::boolean, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.TenantContext)'
        def get_payment_method_by_external_key(paymentMethodExternalKey, includedInactive, withPluginInfo, properties, context)

          # conversion for paymentMethodExternalKey [type = java.lang.String]
          paymentMethodExternalKey = paymentMethodExternalKey.to_s unless paymentMethodExternalKey.nil?

          # conversion for includedInactive [type = boolean]
          includedInactive = includedInactive.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(includedInactive)

          # conversion for withPluginInfo [type = boolean]
          withPluginInfo = withPluginInfo.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(withPluginInfo)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.get_payment_method_by_external_key(paymentMethodExternalKey, includedInactive, withPluginInfo, properties, context)
            # conversion for res [type = org.killbill.billing.payment.api.PaymentMethod]
            res = Killbill::Plugin::Model::PaymentMethod.new.to_ruby(res) unless res.nil?
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end

        java_signature 'Java::org.killbill.billing.util.entity.Pagination getPaymentMethods(Java::java.lang.Long, Java::java.lang.Long, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.TenantContext)'
        def get_payment_methods(offset, limit, withPluginInfo, properties, context)

          # conversion for offset [type = java.lang.Long]
          offset = offset

          # conversion for limit [type = java.lang.Long]
          limit = limit

          # conversion for withPluginInfo [type = boolean]
          withPluginInfo = withPluginInfo.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(withPluginInfo)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
          context = context.to_java unless context.nil?
          res = @real_java_api.get_payment_methods(offset, limit, withPluginInfo, properties, context)
          # conversion for res [type = org.killbill.billing.util.entity.Pagination]
          res = Killbill::Plugin::Model::Pagination.new.to_ruby(res) unless res.nil?
          return res
        end

        java_signature 'Java::org.killbill.billing.util.entity.Pagination searchPaymentMethods(Java::java.lang.String, Java::java.lang.Long, Java::java.lang.Long, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.TenantContext)'
        def search_payment_methods(searchKey, offset, limit, withPluginInfo, properties, context)

          # conversion for searchKey [type = java.lang.String]
          searchKey = searchKey.to_s unless searchKey.nil?

          # conversion for offset [type = java.lang.Long]
          offset = offset

          # conversion for limit [type = java.lang.Long]
          limit = limit

          # conversion for withPluginInfo [type = boolean]
          withPluginInfo = withPluginInfo.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(withPluginInfo)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
          context = context.to_java unless context.nil?
          res = @real_java_api.search_payment_methods(searchKey, offset, limit, withPluginInfo, properties, context)
          # conversion for res [type = org.killbill.billing.util.entity.Pagination]
          res = Killbill::Plugin::Model::Pagination.new.to_ruby(res) unless res.nil?
          return res
        end

        java_signature 'Java::void deletePaymentMethod(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::boolean, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
        def delete_payment_method(account, paymentMethodId, deleteDefaultPaymentMethodWithAutoPayOff, properties, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentMethodId [type = java.util.UUID]
          paymentMethodId = java.util.UUID.fromString(paymentMethodId.to_s) unless paymentMethodId.nil?

          # conversion for deleteDefaultPaymentMethodWithAutoPayOff [type = boolean]
          deleteDefaultPaymentMethodWithAutoPayOff = deleteDefaultPaymentMethodWithAutoPayOff.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(deleteDefaultPaymentMethodWithAutoPayOff)

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          @real_java_api.delete_payment_method(account, paymentMethodId, deleteDefaultPaymentMethodWithAutoPayOff, properties, context)
        end

        java_signature 'Java::void setDefaultPaymentMethod(Java::org.killbill.billing.account.api.Account, Java::java.util.UUID, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
        def set_default_payment_method(account, paymentMethodId, properties, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for paymentMethodId [type = java.util.UUID]
          paymentMethodId = java.util.UUID.fromString(paymentMethodId.to_s) unless paymentMethodId.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          @real_java_api.set_default_payment_method(account, paymentMethodId, properties, context)
        end

        java_signature 'Java::java.util.List refreshPaymentMethods(Java::org.killbill.billing.account.api.Account, Java::java.lang.String, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
        def refresh_payment_methods(account, pluginName, properties, context)

          # conversion for account [type = org.killbill.billing.account.api.Account]
          account = account.to_java unless account.nil?

          # conversion for pluginName [type = java.lang.String]
          pluginName = pluginName.to_s unless pluginName.nil?

          # conversion for properties [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (properties || []).each do |m|
            # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          properties = tmp

          # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
          context = context.to_java unless context.nil?
          begin
            res = @real_java_api.refresh_payment_methods(account, pluginName, properties, context)
            # conversion for res [type = java.util.List]
            tmp = []
            (res || []).each do |m|
              # conversion for m [type = org.killbill.billing.payment.api.PaymentMethod]
              m = Killbill::Plugin::Model::PaymentMethod.new.to_ruby(m) unless m.nil?
              tmp << m
            end
            res = tmp
            return res
          rescue Java::org.killbill.billing.payment.api.PaymentApiException => e
            raise Killbill::Plugin::Model::PaymentApiException.new.to_ruby(e)
          end
        end
      end
    end
  end
end
